/*
 * @Description: API信息 - 接口
 * @Author: DHL
 * @Date: 2022-03-23 13:04:54
 * @LastEditors: DHL
 * @LastEditTime: 2022-07-20 13:11:06
 */

import { $get, $post, $put } from '/@/utils/http'
import { ContentTypeEnum } from '/@/constant/http'
import { ApiListResultModel, ApiModel, ApiPageParams, ApiResultModel } from './model/apiModel'

/**
 * 不分页查询
 */
export const apiApiSearchList = (searchParams: ApiPageParams) =>
  $get<ApiListResultModel>({
    url: '/auth/twbApi/searchList',
    params: searchParams
  })

/**
 * 根据ID获取详情
 */
export const apiApiGetById = (id: string) =>
  $get<ApiResultModel>({
    url: '/auth/twbApi/getById',
    params: { id: id }
  })

/**
 * 保存信息
 */
export const apiApiSave = (saveParams: ApiModel) =>
  $post<ApiResultModel>({
    url: '/auth/twbApi/save',
    contentType: ContentTypeEnum.json,
    params: saveParams
  })

/**
 * 更新信息
 */
export const apiApiUpdateById = (updateParams: ApiModel) =>
  $put<ApiResultModel>({
    url: '/auth/twbApi/updateById',
    contentType: ContentTypeEnum.json,
    params: updateParams
  })

/**
 * 根据ID删除信息
 */
export const apiApiDeleteById = (id: string) =>
  $post<ApiResultModel>({
    url: '/auth/twbApi/deleteById',
    params: { id: id }
  })

/**
 * 批量删除信息
 */
export const apiApiBatchDeleteByIds = (ids: string) =>
  $post<ApiResultModel>({
    url: '/auth/twbApi/batchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 根据ID逻辑删除信息
 */
export const apiApiLogicDeleteById = (id: string) =>
  $post<ApiResultModel>({
    url: '/auth/twbApi/logicDeleteById',
    params: { id: id }
  })

/**
 * 批量逻辑删除
 */
export const apiApiLogicBatchDeleteByIds = (ids: string) =>
  $post<ApiResultModel>({
    url: '/auth/twbApi/logicBatchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 获取资源配置的api集合
 * @param resourceId
 * @returns
 */
export const apiApiListApiIdsByResourceId = (resourceId: string) =>
  $get<ApiListResultModel>({
    url: '/auth/twbApi/listApiIdsByResourceId',
    params: { resourceId: resourceId }
  })
